#include <iostream>
#include <queue>
#include <unordered_set>
using namespace std;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int m, n, word, ans = 0;
  queue<int> que;
  unordered_set<int> s;

  cin >> m >> n;
  for (int i = 0; i < n; i++) {
    cin >> word;
    if (s.find(word) == s.end()) {
      que.push(word);
      s.insert(word);
      ans++;
      if (que.size() > m) {
        s.erase(que.front());
        que.pop();
      }
    }
  }
  cout << ans << "\n";
  return 0;
}